<template>
	<view class="container">
		<top-back-navbar position="fixed" title="提现" background="" color="#fff"></top-back-navbar>
		<cxsytabbars :current="2"></cxsytabbars>
		<view class="title">
			{{title}}
		</view>
		<view class="shouyi_num">
			<p style="margin-top: 12px;">￥</p>
			<p style="font-size: 31px;">{{qianbao_data.credit2}}</p>
		</view>
		<view class="tx_box">
			<view class="box">
				<view class="title">
					<view class="txt">
						提现金额
					</view>
					<view class="mingx" @click="to_nextpage('/pagesZA/qianbao/mingxi?type=za_shouyi&r=api.index.get_za_mingxi_list&title=收益明细&hander=我的收益')">
						明细
					</view>
				</view>
				
				<!-- <view class="">
					<view class="uni-list-cell-db" v-if="bank_list.length>0">
						<picker @change="professionchange"  :range="bank_list" range-key="bankname">
							<view class="uni-input">{{bank_list[bank_index].bankname}} &nbsp;{{bank_list[bank_index].bankid}}</view>
						</picker>
					</view>
				</view> -->
				<view class="input_box">
					<input type="number" v-model="money" placeholder="输入金额"/>
					<view class="button" @click="tixian">
						确定
					</view>
				</view>
				<view class="bank_box" v-show="bank_sure==0">
					<view class="">
						银行卡信息
					</view>
					<view class="">
						开户名称:&nbsp;&nbsp;&nbsp;{{bank_list.accountName}}
					</view>
					<view class="">
						开户账号:&nbsp;&nbsp;&nbsp;{{bank_list.bankCardNo}}
					</view>
					<view class="">
						开户银行:&nbsp;&nbsp;&nbsp;{{bank_list.bankname}}
					</view>
					<view class="">
						开户网点:&nbsp;&nbsp;&nbsp;{{bank_list.bankbranch}}
					</view>
					
				</view>
				<view class="bank_box" v-show="bank_sure!=0">
					<view class="" style="color: red;">
						{{bank_list}}
					</view>
					
					
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				nonBreakingSpace: '\u00A0\u00A0\u00A0',
				tixian_x: 0,
				tixian_y: 0,
				openid:0,
				shouyi:0,
				n: true,
				txi:0,
				bank_index:0,
				bank_list:[],
				qianbao_data:{},
				money:'',
				tx_type:'',
				title:'',
				bank_sure:0
			};
		},
		onLoad: function(e) {
			console.log(e.type,e.title);
			this.title=e.title
			if(e.type== 'none'){
				this.tx_type=''
				
			}else{
				this.tx_type=e.type
			
			}
			var _this = this
			var id = uni.getStorage({
				key: 'openid',
				success: function(res) {
					var id = res.data
					
					_this.openid = id
					_this.get_datas()
					_this.get_data()
				},
				fail: function(err) {
					uni.hideLoading()
					uni.reLaunch({
						url: '/pages/login/login'
					});
				}
			});
			
			
			this.tixian_x = 0
			this.tixian_y = 0
			this.n=false
		},
		methods: {
			tixiansure(){
				var _this=this
				
				var data= this.bank_list[this.bank_index]
				uni.request({
					url: `${this.$BASE_URL}/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.withdraw.submit&app=1&applytype=3`,
					method: 'POST',
					data: {
						'openid': data.openid,
						'money': this.money,
						'realname':data.bankuser,
						'bankname':data.bankname,
						'bankbranch':data.bankbranch,
						'bankcard':data.bankid,
						'type':_this.tx_type
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						var data =res.data
					
						if(data.status==0){
							uni.showToast({
								icon:'none',
								title:data.result.message,
								duration:1500
							})
						}else if(data.status==1){
							uni.showToast({
								icon:'none',
								title:data.result.message,
								duration:1500,
								success() {
									setTimeout(()=>{
										_this.get_datas()
										_this.get_data()
									},1500)
								}
							})
						}
					},
					fail: () => {},
					complete: () => {}
				})
			},
			tixian(){
					var _this=this
				uni.showModal({
					icon:'none',
					title:`确认提现${this.money}吗`,
					success(res) {
						if(res.confirm){
							_this.tixiansure()
						}
					}
				})
				
			},
			to_nextpage(path){
				console.log(path);
				uni.navigateTo({
					url: path
				});
			},
			professionchange(e){
				
				this.bank_index=e.detail.value
			},
		get_datas() {
			var openid = this.openid
			uni.showLoading()
			uni.request({
				url: this.$BASE_URL +
					'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1&type=za&openid=' +
					openid,
		
				success: res => {
					var data = res.data
					var code = data.error
					if (code == 1) {
						uni.navigateTo({
							url: '/pagesZA/home/home'
						});
					} else {
						this.qianbao_data = data
					}
				
				},
				fail: () => {},
				complete: () => {
					uni.hideLoading();
				}
			});
		},
			get_data() {
				var openid = this.openid
				var _this=this
				uni.request({
					url: this.$BASE_URL +
						'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.show_zishanghu_info&app=1&type=za&openid=' +
						openid,
				
					success: res => {
						var data = res.data
						var code = data.error
						_this.bank_sure=code
						if (code != 0) {
							uni.showToast({
								icon:'none',
								title:data.message
							})
							_this.bank_list=data.message
						} else {
							_this.bank_list=data.info
						}
					},
					fail: () => {},
					complete: () => {
						uni.hideLoading();
					}
				});
			},
			
		}
	}
</script>

<style lang="less">
	page {
		height: 100%;
	
	}

	.container {

		height:calc(100vh - 100rpx);
		background: url('/static/zn/hander_bg.png')0 0 no-repeat;
		// background-size: 150% 106%;

		background-size: 100%;
		position: relative;
		padding: 0 10px;
		overflow: auto;
		padding: 0 20px;
		background-color: #fafafa;
	}
	.title{
		width: 100%;
		text-align: center;
		color: #fff;
		font-size: 20px;
		font-weight: 800;
	}
	.shouyi_num{
		width: 100%;
		display: flex;
		justify-content: center;
		background: linear-gradient(to bottom, #FBEDB9, #FFB85C, );
		align-items: center;
		background-clip: text;
		color: transparent;
		font-weight: 800;
	}
	.bank_box{
		padding: 0 20px;
	}
	.tx_box{
	
		width: 100%;
		// height: 250px;
			background-color: #fff;
		
			padding: 12px 10px 20px;
			border-radius: 20px;
			.box{
				width: 100%;
				height: 100%;
			
				.title{
					display: flex;
					justify-content: space-between;
					padding: 0 20px;
					height: 50px;
					align-items: center;
					.txt{
						font-size: 20px;
						font-weight: 800;
						color: #000;
						line-height: 50px;
					}
					.txt2{
						color: #8A8A8A;
						font-size:18px;
						line-height: 50px;
					}
				}
			}
			
			.uni-list-cell-db{
				margin: 15px 0;
				margin-left: 20px;
				
				.uni-input{
					color: #878787;
					font-size: 12px;
				}
			}
	}
	
	.input_box{
		width: 100%;
		height: 60px;
		
		display: flex;
		align-items: center;
		justify-content: space-around;
		input{
			width: 50%;
			height: 40px;
			border-bottom: 1px solid #8a8a8a;
			text-align: center;
			font-size: 20px;
			font-weight: 800;
			color: #000;
		}
		.button{
			width: 40%;
			background-color: #6A41EA;
			color: #fff;
			height: 40px;
			line-height: 40px;
			text-align: center;
			border-radius: 50px;
		}
	}
	.mingx{
		margin: 5px 10px;
		width: 70px;
		color: #8a8a8a;
		border:1px solid #8a8a8a;
		border-radius: 50px;
		height: 25px;
		line-height: 25px;
		text-align: center;
	}
</style>